// ActionScript file
package com.app.commands{
    import com.adobe.cairngorm.commands.ICommand;
    import com.adobe.cairngorm.control.CairngormEvent;
    import com.app.business.LoginDelegate;
    import com.app.control.LogoutEvent;
    import com.app.model.ModelLocator;
    import com.app.vo.VO;
    
    import mx.rpc.IResponder;
    
    public class LogoutCommand implements ICommand,IResponder
    {
        private var model:ModelLocator = ModelLocator.getInstance();
        public function execute(event:CairngormEvent):void{
            model.login.isPending=true;
            var delegate:LoginDelegate = new LoginDelegate(this);
            var logoutEvent : LogoutEvent = LogoutEvent( event );  
            delegate.logout(logoutEvent.loginVO);
        }
        
        public function result(data:Object):void{
            model.login.isPending=false;
            model.login.loginVO=VO(data);
            model.workflowState=ModelLocator.VIEWING_LOGIN_SCREEN;
        }
        
        public function fault( info :Object):void{
            model.login.isPending = false;
        }

    }
}
